 Ext.ns("Jinyi.project");

Jinyi.project.Attachment = function (config) {
	this.width= 760;
	this.height= 420;
	this.title= "文件管理";
	this.partId= "";
	this.tableId = "";
	this.tableName = "";
	this.tableField = "";
	this.type = "word";
	this.fileName ="";
	this.remark = "";
	this.fieldData =[['工程文件','工程文件']];
	this.url ='/'+appConfig.appName+'/attachment/uploadFiles.jsp';
	 Ext.apply(this, config);
};

Jinyi.project.Attachment.prototype = {
  init: function (partId, tableId, tableName, tableField, type) {
	this.partId= partId;
	this.tableId = tableId;
	this.tableName = tableName;
	this.type =  type;
	if(this.isArray(tableField)){
	 this.fieldData =tableField;
	} else{
		 if(tableField && type){
		   this.tableField = tableField;
		   this.fieldData=[[tableField,type]];
		}
	}
	 top.fieldData = this.fieldData;
	}, 
   toURL: function () {
	 return this.url+'?partId='+this.partId+'&tableId='+this.tableId+'&tableName='+this.tableName+'&tableField='+this.tableField;
	},    
	isArray: function(o) { 
       return Object.prototype.toString.call(o) === '[object Array]';   
    },
   getTypeData:function (){},
   
   showUpload: function(_title,_width,_height){
    var title = this.title;
    var width = this.width;
    var height= this.height;
   	if(_title) {title = _title;}
   	if(_width) {width = _width;}
    if(_height){height = _height;}
	var url =this.toURL();
    top.showWindowModel(title,width,height,url,"attachment") ;
   },
   
   showUploadJquery: function(_title,_width,_height){
	var title = this.title;
	var width = this.width;
	var height= this.height;
	if(_title) {title = _title;}
	if(_width) {width = _width;}
	if(_height){height = _height;}
	var url =this.toURL();
	top.showWindow(title,url,{height:400,width:760});
   }
};
var projectAttachment = new Jinyi.project.Attachment();


